home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / DDPLUS71.ZIP / RIPLINK.ZIP / RIPLINK.PA1 < prev    next >
Encoding:
Text File  |  1994-06-25  |  29.6 KB  |  1,238 lines

  1. {Include file for RipLink(tm) - Copyright (C) 1994 by InterProgramming}
  2. {                               All rights reserved                   }
  3.  
  4. {This include file contains the majority of the actual display routines for
  5.  RIPlink.  RIPLINK.PAS containes the routines to parse/process the RIPscrip
  6.  commands.  }
  7.  
  8. Procedure RipObj.rTextWindow(x0,y0,x1,y1:byte; wrap:boolean; size:byte);
  9. begin
  10.   if LocalRip then
  11.   begin
  12.     {$IFDEF MOUSE}
  13.     MouseOff;
  14.     {$ENDIF}
  15.     if (x0=0) and (y0=0) and (x1=0) and (y1=0) then
  16.       textactive := false
  17.     else
  18.     begin
  19.       if (x0 = textx0) and (y0 = texty0) and (x1 = textx1) and (y1 = texty1) and (size = textsize) then
  20.         textwrap := wrap
  21.       else
  22.       begin
  23.         textx0 := x0;     texty0 := y0;
  24.         textx1 := x1;     texty1 := y1;
  25.         textsize := size; textwrap := wrap;
  26.         textactive := true;
  27.         textclr := 15;
  28.         fillchar(virtualwindow,7826,#0);
  29.         rHome;
  30.       end;
  31.     end;
  32.     statline;
  33.     {$IFDEF MOUSE}
  34.     MouseOn;
  35.     {$ENDIF}
  36.   end;
  37. end;
  38.  
  39. Procedure RipObj.rViewPort(x0,y0,x1,y1:word);
  40. begin
  41.   if LocalRip then
  42.   begin
  43.     {$IFDEF MOUSE}
  44.     MouseOff;
  45.     {$ENDIF}
  46.     {textcolor(0);}
  47.     setviewport(x0,y0,x1,y1,true);
  48.     statline;
  49.     {$IFDEF MOUSE}
  50.     MouseOn;
  51.     {$ENDIF}
  52.   end;
  53. end;
  54.  
  55. Procedure RipObj.rResetWindows;
  56. begin
  57.   if LocalRip then
  58.   begin
  59.     {$IFDEF MOUSE}
  60.     KillRegions;
  61.     MouseOff;
  62.     {$ENDIF}
  63.     textx0 := 0;  texty0 := 0;
  64.     textx1 := 79; texty1 := 42;
  65.     textsize := 0;
  66.     textwrap := true;
  67.     textactive := true;
  68.     textclr := 15;
  69.     cursorx := 0; cursory := 0;
  70.     cursoron := false;
  71.     fillchar(virtualwindow,7826,#0);
  72.     SetViewPort(0,0,GetMaxX,GetMaxY-12,ClipOn);
  73.     ClearViewPort;
  74.     graphdefaults;
  75.     settextjustify(lefttext,toptext);
  76.     DefColor := GetColor;
  77.     CurFont := 0;
  78.     CurSize := 1;
  79.     Metric := MetricArray[CurFont,CurSize];
  80.     if clipb <> nil then
  81.     begin
  82.       FreeMem(ClipB,ClipSize);
  83.       ClipSize := 0;
  84.       ClipB := nil;
  85.     end;
  86.     statline;
  87.     {$IFDEF MOUSE}
  88.     MouseOn;
  89.     {$ENDIF}
  90.   end;
  91. end;
  92.  
  93. Procedure RipObj.rEraseWindow;
  94. var
  95.   fst : fillsettingstype;
  96. begin
  97.   if LocalRip and TextActive then
  98.   begin
  99.     {$IFDEF MOUSE}
  100.     MouseOff;
  101.     {$ENDIF}
  102.     getfillsettings(fst);
  103.     setfillstyle(0,fst.color);
  104.     fillchar(virtualwindow,7826,#0);
  105.     Bar(TextOffsetX[textsize]*textx0,TextOffsetY[textsize]*texty0,
  106.         TextOffsetX[textsize]*(textx1+1)-1,TextOffsetY[textsize]*(texty1+1)-1);
  107.     setfillstyle(fst.pattern,fst.color);
  108.     rHome;
  109.     statline;
  110.     {$IFDEF MOUSE}
  111.     MouseOn;
  112.     {$ENDIF}
  113.   end;
  114. end;
  115.  
  116. Procedure RipObj.rEraseView;
  117. begin
  118.   if LocalRip then
  119.   begin
  120.     {$IFDEF MOUSE}
  121.     MouseOff;
  122.     {$ENDIF}
  123.     ClearViewPort;
  124.     statline;
  125.     {$IFDEF MOUSE}
  126.     MouseOn;
  127.     {$ENDIF}
  128.   end;
  129. end;
  130.  
  131. Procedure RipObj.rGotoXY(x0,y0:byte);
  132. begin
  133.   if LocalRip and textactive then
  134.   begin
  135.     {$IFDEF MOUSE}
  136.     MouseOff;
  137.     {$ENDIF}
  138.     cursorx := textx0+x0;
  139.     cursory := texty0+y0;
  140.     {$IFDEF MOUSE}
  141.     MouseOn;
  142.     {$ENDIF}
  143.   end;
  144. end;
  145.  
  146. Procedure RipObj.rHome;
  147. begin
  148.   if LocalRip then
  149.   begin
  150.     {$IFDEF MOUSE}
  151.     MouseOff;
  152.     {$ENDIF}
  153.     cursorx := textx0;
  154.     cursory := texty0;
  155.     {$IFDEF MOUSE}
  156.     MouseOn;
  157.     {$ENDIF}
  158.   end;
  159. end;
  160.  
  161. Procedure RipObj.rEraseEOL;
  162. var
  163.   fst : fillsettingstype;
  164.   ctr : byte;
  165. begin
  166.   if LocalRip and TextActive then
  167.   begin
  168.     {$IFDEF MOUSE}
  169.     MouseOff;
  170.     {$ENDIF}
  171.     getfillsettings(fst);
  172.     setfillstyle(0,fst.color);
  173.     {fillchar(virtualwindow,7826,#0);}
  174.     Bar(TextOffsetX[textsize]*cursorx,TextOffsetY[textsize]*cursory,
  175.         TextOffsetX[textsize]*(textx1+1)-1,TextOffsetY[textsize]*(cursory+1)-1);
  176.     setfillstyle(fst.pattern,fst.color);
  177.     for ctr := cursorx to TextMaxX[textsize] do
  178.       virtualwindow[ctr,cursory,0] := 0;
  179.     rHome;
  180.     statline;
  181.     {$IFDEF MOUSE}
  182.     MouseOn;
  183.     {$ENDIF}
  184.   end;
  185. end;
  186.  
  187. Procedure RipObj.rColor(clr:byte);
  188. begin
  189.   if LocalRip then
  190.   begin
  191.     SetColor(clr);
  192.     DefColor := clr;
  193.   end;
  194. end;
  195.  
  196. Procedure RipObj.rSetPalette(c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15,c16:word);
  197. var
  198.   palette       : palettetype;
  199. begin
  200.   with palette do
  201.   begin
  202.     size := 16;
  203.     colors[0]  := c1;
  204.     colors[1]  := c2;
  205.     colors[2]  := c3;
  206.     colors[3]  := c4;
  207.     colors[4]  := c5;
  208.     colors[5]  := c6;
  209.     colors[6]  := c7;
  210.     colors[7]  := c8;
  211.     colors[8]  := c9;
  212.     colors[9]  := c10;
  213.     colors[10] := c11;
  214.     colors[11] := c12;
  215.     colors[12] := c13;
  216.     colors[13] := c14;
  217.     colors[14] := c15;
  218.     colors[15] := c16;
  219.   end;
  220.   if LocalRip then
  221.     SetAllPalette(Palette);
  222. end;
  223.  
  224. Procedure RipObj.rOnePalette(color,value:word);
  225. begin
  226.   if LocalRip then
  227.     SetPalette(color,value);
  228. end;
  229.  
  230. Procedure RipObj.rWriteMode(mode:byte);
  231. begin
  232.   if LocalRip then
  233.     SetWriteMode(mode);
  234. end;
  235.  
  236. Procedure RipObj.rMove(x0,y0:word);
  237. begin
  238.   if LocalRip then
  239.     MoveTo(x0,y0);
  240. end;
  241.  
  242. Procedure RipObj.rText(instr:string);
  243. begin
  244.   if LocalRip then
  245.   begin
  246.     {$IFDEF MOUSE}
  247.     MouseOff;
  248.     {$ENDIF}
  249.     settextjustify(lefttext,toptext);
  250.     OutText(instr);
  251.     {$IFDEF MOUSE}
  252.     MouseOn;
  253.     {$ENDIF}
  254.   end;
  255. end;
  256.  
  257. Procedure RipObj.rTextXY(x0,y0:word; instr:string);
  258. begin
  259.   if not LocalRip then
  260.     exit;
  261.   {$IFDEF MOUSE}
  262.   MouseOff;
  263.   {$ENDIF}
  264.   settextjustify(lefttext,toptext);
  265.   outtextxy(x0,y0,instr);
  266.   {$IFDEF MOUSE}
  267.   MouseOn;
  268.   {$ENDIF}
  269. end;
  270.  
  271. Procedure RipObj.rFontStyle(font,direct,size:byte);
  272. begin
  273.   if LocalRip then
  274.   begin
  275.     {$IFDEF FONTFILE}
  276.     if fontptr <> nil then
  277.     begin
  278.       freemem(fontptr,fontsize);
  279.       fontptr := nil;
  280.     end;
  281.     case font of
  282.       1  : begin fontsize := 16677; seek(charfile,  5527); end;
  283.       2  : begin fontsize :=  5131; seek(charfile, 22204); end;
  284.       3  : begin fontsize := 13596; seek(charfile, 27335); end;
  285.       4  : begin fontsize := 18063; seek(charfile, 40931); end;
  286.       5  : begin fontsize := 10987; seek(charfile, 58994); end;
  287.       6  : begin fontsize :=  8437; seek(charfile, 69981); end;
  288.       7  : begin fontsize := 17355; seek(charfile, 78418); end;
  289.       8  : begin fontsize := 12083; seek(charfile, 95773); end;
  290.       9  : begin fontsize :=  8439; seek(charfile,107856); end;
  291.       10 : begin fontsize := 14670; seek(charfile,116295); end;
  292.     end;
  293.     if font <> 0 then
  294.     begin
  295.       getmem(fontptr,fontsize);
  296.       blockread(charfile,fontptr^,fontsize);
  297.       if registerbgifont(fontptr) < 0 then ;
  298.     end;
  299.     {$ENDIF}
  300.     SetTextStyle(font,direct,size);
  301.     CurFont := font;
  302.     CurSize := size;
  303.     Metric := MetricArray[CurFont,CurSize];
  304.   end;
  305. end;
  306.  
  307. Procedure RipObj.rPixel(x0,y0:word);
  308. begin
  309.   if LocalRip then
  310.   begin
  311.     {$IFDEF MOUSE}
  312.     MouseOff;
  313.     {$ENDIF}
  314.     PutPixel(x0,y0,defcolor);
  315.     {$IFDEF MOUSE}
  316.     MouseOn;
  317.     {$ENDIF}
  318.   end;
  319. end;
  320.  
  321. Procedure RipObj.rLine(x0,y0,x1,y1:word);
  322. begin
  323.   if LocalRip then
  324.   begin
  325.     {$IFDEF MOUSE}
  326.     MouseOff;
  327.     {$ENDIF}
  328.     Line(x0,y0,x1,y1);
  329.     {$IFDEF MOUSE}
  330.     MouseOn;
  331.     {$ENDIF}
  332.   end;
  333. end;
  334.  
  335. Procedure RipObj.rRectangle(x0,y0,x1,y1:word);
  336. begin
  337.   if LocalRip then
  338.   begin
  339.     {$IFDEF MOUSE}
  340.     MouseOff;
  341.     {$ENDIF}
  342.     Rectangle(x0,y0,x1,y1);
  343.     {$IFDEF MOUSE}
  344.     MouseOn;
  345.     {$ENDIF}
  346.   end;
  347. end;
  348.  
  349. Procedure RipObj.rBar(x0,y0,x1,y1:word);
  350. begin
  351.   if LocalRip then
  352.   begin
  353.     {$IFDEF MOUSE}
  354.     MouseOff;
  355.     {$ENDIF}
  356.     Bar(x0,y0,x1,y1);
  357.     {$IFDEF MOUSE}
  358.     MouseOn;
  359.     {$ENDIF}
  360.   end;
  361. end;
  362.  
  363. Procedure RipObj.rCircle(x0,y0,radius:word);
  364. begin
  365.   if LocalRip then
  366.   begin
  367.     {$IFDEF MOUSE}
  368.     MouseOff;
  369.     {$ENDIF}
  370.     Circle(x0,y0,radius);
  371.     {$IFDEF MOUSE}
  372.     MouseOn;
  373.     {$ENDIF}
  374.   end;
  375. end;
  376.  
  377. Procedure RipObj.rOval(x0,y0,stangle,endangle,xrad,yrad:word);
  378. begin
  379.   if LocalRip then
  380.   begin
  381.     {$IFDEF MOUSE}
  382.     MouseOff;
  383.     {$ENDIF}
  384.     Ellipse(x0,y0,stangle,endangle,xrad,yrad);
  385.     {$IFDEF MOUSE}
  386.     MouseOn;
  387.     {$ENDIF}
  388.   end;
  389. end;
  390.  
  391. Procedure RipObj.rFilledOval(x0,y0,xrad,yrad:word);
  392. begin
  393.   if LocalRip then
  394.   begin
  395.     {$IFDEF MOUSE}
  396.     MouseOff;
  397.     {$ENDIF}
  398.     FillEllipse(x0,y0,xrad,yrad);
  399.     {$IFDEF MOUSE}
  400.     MouseOn;
  401.     {$ENDIF}
  402.   end;
  403. end;
  404.  
  405. Procedure RipObj.rArc(x0,y0,stangle,endangle,rad:word);
  406. begin
  407.   if LocalRip then
  408.   begin
  409.     {$IFDEF MOUSE}
  410.     MouseOff;
  411.     {$ENDIF}
  412.     Arc(x0,y0,stangle,endangle,rad);
  413.     {$IFDEF MOUSE}
  414.     MouseOn;
  415.     {$ENDIF}
  416.   end;
  417. end;
  418.  
  419. Procedure RipObj.rPieSlice(x0,y0,stangle,endangle,rad:word);
  420. begin
  421.   if LocalRip then
  422.   begin
  423.     {$IFDEF MOUSE}
  424.     MouseOff;
  425.     {$ENDIF}
  426.     PieSlice(x0,y0,stangle,endangle,rad);
  427.     {$IFDEF MOUSE}
  428.     MouseOn;
  429.     {$ENDIF}
  430.   end;
  431. end;
  432.  
  433. Procedure RipObj.rOvalPieSlice(x0,y0,stangle,endangle,radx,rady:word);
  434. begin
  435.   if LocalRip then
  436.   begin
  437.     {$IFDEF MOUSE}
  438.     MouseOff;
  439.     {$ENDIF}
  440.     Sector(x0,y0,stangle,endangle,radx,rady);
  441.     {$IFDEF MOUSE}
  442.     MouseOn;
  443.     {$ENDIF}
  444.   end;
  445. end;
  446.  
  447. Procedure RipObj.rBezier(x0,y0,x1,y1,x2,y2,x3,y3,count:word);
  448. type
  449.   coord = record
  450.     x,y : integer;
  451.   end;
  452.  
  453.   CurveDataRec = array[0..65521 div sizeof(coord)] of coord;
  454.  
  455. var
  456.   bezarray                  : array [0..3] of coord;
  457.  
  458.   procedure drawBezier(var d0:coord;nPoints,nSteps:word; colr : byte);
  459.   {Formula:            3            2       2           3
  460.          Q(t) = (1 - t) P1 + 3t(1-t) P2 + 3t (1-t)P3 + t P4
  461.   }
  462.   const
  463.     nsa = 1/6;
  464.     nsb = 2/3;
  465.   var
  466.     i,i2,i3,xx,yy                             : integer;
  467.     {$IFDEF DOUBLENUM}
  468.     t,tm3,t2,t2m3,t3,t3m3,nc1,nc2,nc3,nc4,step: double;
  469.     {$ELSE}
  470.     t,tm3,t2,t2m3,t3,t3m3,nc1,nc2,nc3,nc4,step: real;
  471.     {$ENDIF}
  472.     d                                         : curveDataRec absolute d0;
  473.     oldx, oldy                                : integer;
  474.   begin
  475.     step := 1/nSteps;
  476.     oldx := d[0].x;
  477.     oldy := d[0].y;
  478.     setcolor(colr);
  479.     for i2 := 0 to pred(nPoints) div 4 do
  480.     begin
  481.       i := i2*4;
  482.       t := 0.0;
  483.       for i3 := pred(nSteps) downto 0 do
  484.       begin
  485.         t    := t+step;
  486. {        t2   := (1-t);
  487.         xx := round(t2*t2*t2*d[i].x + 3.0*t*t2*t2*d[i+1].x +
  488.                     3.0*t*t*t2*d[i+2].x +   t*t*t*d[i+3].x);
  489.         yy := round(t2*t2*(1-t)*d[i].y + 3.0*t*t2*t2*d[i+1].y +
  490.                     3.0*t*t*t2*d[i+2].y +   t*t*t*d[i+3].y);
  491. }
  492.         tm3  := t*3.0;
  493.         t2   := t*t;
  494.         t2m3 := t2*3.0;
  495.         t3   := t2*t;
  496.         t3m3 := t3*3.0;
  497.         nc1  := 1-tm3+t2m3-t3;
  498.         nc2  := t3m3-2.0*t2m3+tm3;
  499.         nc3  := t2m3-t3m3;
  500.         nc4  := t3;
  501.         xx := trunc(nc1*d[i].x+nc2*d[succ(i)].x+nc3*d[i+2].x+nc4*d[i+3].x);
  502.         yy := trunc(nc1*d[i].y+nc2*d[succ(i)].y+nc3*d[i+2].y+nc4*d[i+3].y);
  503.         if (oldx = 0) and (oldy = 0) then
  504.         begin
  505.           putpixel(xx,yy, colr);
  506.           oldx := xx;
  507.           oldy := yy;
  508.         end
  509.         else
  510.         begin
  511.           line(oldx, oldy, xx, yy);
  512.           oldx := xx;
  513.           oldy := yy;
  514.         end;
  515.       end;
  516.     end;
  517.   end;
  518.  
  519. begin
  520.   if not LocalRip then
  521.     exit;
  522.   {$IFDEF MOUSE}
  523.   MouseOff;
  524.   {$ENDIF}
  525.   bezarray[0].X := x0;
  526.   bezarray[0].Y := y0;
  527.   bezarray[1].X := x1;
  528.   bezarray[1].Y := y1;
  529.   bezarray[2].X := x2;
  530.   bezarray[2].Y := y2;
  531.   bezarray[3].X := x3;
  532.   bezarray[3].Y := y3;
  533.   drawBezier(bezarray[0],4,count,defcolor);
  534.   {$IFDEF MOUSE}
  535.   MouseOn;
  536.   {$ENDIF}
  537. end;
  538.  
  539. Procedure RipObj.rPolygon(numpoints:word; var PolyPoints; complete:boolean);
  540. type
  541.   PointRec = record
  542.     X : word;
  543.     Y : word;
  544.   end;
  545.  
  546.   TempType = Array[1..512] of PointRec;
  547. var
  548.   polytemp : temptype;
  549. begin
  550.   if LocalRip then
  551.   begin
  552.     {$IFDEF MOUSE}
  553.     MouseOff;
  554.     {$ENDIF}
  555.     polytemp := temptype(polypoints);
  556.     if complete then
  557.     begin
  558.       polytemp[numpoints+1].X := polytemp[1].X;
  559.       polytemp[numpoints+1].Y := polytemp[1].Y;
  560.       drawpoly(numpoints+1,polytemp);
  561.     end
  562.     else
  563.       drawpoly(numpoints,polytemp);
  564.     {$IFDEF MOUSE}
  565.     MouseOn;
  566.     {$ENDIF}
  567.   end;
  568. end;
  569.  
  570. Procedure RipObj.rFillPoly(numpoints:word; var polypoints);
  571. begin
  572.   if LocalRip then
  573.   begin
  574.     {$IFDEF MOUSE}
  575.     MouseOff;
  576.     {$ENDIF}
  577.     fillpoly(numpoints,polypoints);
  578.     {$IFDEF MOUSE}
  579.     MouseOn;
  580.     {$ENDIF}
  581.   end;
  582. end;
  583.  
  584. Procedure RipObj.rFill(x0,y0,border:word);
  585. begin
  586.   if LocalRip then
  587.   begin
  588.     {$IFDEF MOUSE}
  589.     MouseOff;
  590.     {$ENDIF}
  591.     FloodFill(x0,y0,border);
  592.     {$IFDEF MOUSE}
  593.     MouseOn;
  594.     {$ENDIF}
  595.   end
  596. end;
  597.  
  598. Procedure RipObj.rLineStyle(style,pattern,thick:word);
  599. begin
  600.   if LocalRip then
  601.     SetLineStyle(style,pattern,thick);
  602. end;
  603.  
  604. Procedure RipObj.rFillStyle(style,color:word);
  605. begin
  606.   if LocalRip then
  607.     SetFillStyle(style,color);
  608. end;
  609.  
  610. Procedure RipObj.rFillPattern(pattern:fpt; color:word);
  611. begin
  612.   if LocalRip then
  613.   begin
  614.     SetFillStyle(UserFill,color);
  615.     SetFillPattern(fillpatterntype(pattern),color);
  616.   end;
  617. end;
  618.  
  619. Procedure RipObj.rMouse(x0,y0,x1,y1:word; inv,reset:boolean; instr:string);
  620. begin
  621.   {$IFDEF MOUSE}
  622.   AddRegion(x0,y0,x1,y1,inv,reset,instr);
  623.   {$ENDIF}
  624. end;
  625.  
  626. Procedure RipObj.rKillMouse;
  627. begin
  628.   {$IFDEF MOUSE}
  629.   KillRegions;
  630.   {$ENDIF}
  631. end;
  632.  
  633. Procedure RipObj.rGetImage(x0,y0,x1,y1:word);
  634. begin
  635.   if LocalRip then
  636.   begin
  637.     {$IFDEF MOUSE}
  638.     MouseOff;
  639.     {$ENDIF}
  640.     if ClipB <> nil then
  641.     begin
  642.       FreeMem(ClipB,ClipSize);
  643.       ClipSize := 0;
  644.       ClipB := nil;
  645.     end;
  646.     ClipSize := ImageSize(x0,y0,x1,y1);
  647.     GetMem(ClipB,ClipSize);
  648.     GetImage(x0,y0,x1,y1,ClipB^);
  649.     {$IFDEF MOUSE}
  650.     MouseOn;
  651.     {$ENDIF}
  652.   end;
  653. end;
  654.  
  655. Procedure RipObj.rPutImage(x0,y0,mode:word);
  656. begin
  657.   if LocalRip then
  658.   begin
  659.     if ClipB = nil then
  660.       Exit;
  661.     {$IFDEF MOUSE}
  662.     MouseOff;
  663.     {$ENDIF}
  664.     PutImage(x0,y0,ClipB^,mode);
  665.     {$IFDEF MOUSE}
  666.     MouseOn;
  667.     {$ENDIF}
  668.   end;
  669. end;
  670.  
  671. Procedure RipObj.rWriteIcon(fname:str12);
  672. var
  673.   IcnFile       : File;
  674.   tname         : string;
  675. begin
  676.   if LocalRip then
  677.   begin
  678.     if ClipB = nil then
  679.       Exit;
  680.     {$IFDEF MOUSE}
  681.     MouseOff;
  682.     {$ENDIF}
  683.     filemode := $02;
  684.     tname := backslash(icondir)+fname;
  685.     if pos('.',tname) = 0 then
  686.       tname := tname + '.ICN';
  687.     assign(IcnFile,tname);
  688.     {$I-}
  689.     rewrite(IcnFile,1);
  690.     {$I+}
  691.     if IOresult <> 0 then
  692.     begin
  693.       {$IFDEF MOUSE}
  694.       MouseOn;
  695.       {$ENDIF}
  696.       exit;
  697.     end;
  698.     blockwrite(IcnFile,ClipB^,ClipSize);
  699.     close(icnfile);
  700.     {$IFDEF MOUSE}
  701.     MouseOn;
  702.     {$ENDIF}
  703.  
  704.   end;
  705. end;
  706.  
  707. Procedure RipObj.rLoadIcon(x0,y0,mode:word; clipbrd:boolean; fname:str12);
  708. var
  709.   cb            : pointer;
  710.   cb2           : pointer;
  711.   cbsize        : word;
  712.   IcnFile       : file;
  713.   thewid,thehgt : word;
  714. begin
  715.   if LocalRip then
  716.   begin
  717.     filemode := $20;
  718.     assign(icnfile,backslash(IconDir)+fname);
  719.     {$I-}
  720.     reset(icnfile,1);
  721.     if IOresult <> 0 then
  722.       exit;
  723.     {$I+}
  724.     {$IFDEF MOUSE}
  725.     MouseOff;
  726.     {$ENDIF}
  727.     seek(IcnFile,0);
  728.     blockread(IcnFile,thewid,2);
  729.     blockread(IcnFile,thehgt,2);
  730.     cbsize := ImageSize(0,0,thewid,thehgt);
  731.     getmem(cb,cbsize);
  732.     seek(IcnFile,0);
  733.     blockread(IcnFile,cb^,cbsize);
  734.     close(icnfile);
  735.     PutImage(x0,y0,cb^,mode);
  736.     if clipbrd then
  737.     begin
  738.       if clipb <> nil then
  739.       begin
  740.         FreeMem(ClipB,ClipSize);
  741.         ClipSize := 0;
  742.         ClipB := nil;
  743.       end;
  744.       clipsize := cbsize;
  745.       GetMem(ClipB,ClipSize);
  746.       Move(cb^,clipb^,clipsize);
  747.     end;
  748.     freemem(cb,cbsize);
  749.     {$IFDEF MOUSE}
  750.     MouseOn;
  751.     {$ENDIF}
  752.   end;
  753. end;
  754.  
  755. Procedure RipObj.rButtonStyle(wid,hgt,orient,flags,bevsize,dfore,dback,bright,dark,
  756.                               surface,grp_no,flags2,uline_col,corner_col:word);
  757. begin
  758.   ButPlainWidth       := wid;
  759.   ButPlainHeight      := hgt;
  760.   ButOrientation      := orient;
  761.   ButFlags            := flags;
  762.   ButBevelSize        := bevsize;
  763.   ButLabelFore        := dfore;
  764.   ButLabelDropShadow  := dback;
  765.   ButPlainHilite      := bright;
  766.   ButPlainShadow      := dark;
  767.   ButPlainSurface     := surface;
  768.   ButGroupNum         := grp_no;
  769.   ButFlags2           := flags2;
  770.   ButLabelUnderline   := uline_col;
  771.   ButCorner           := corner_col;
  772. end;
  773.  
  774. Procedure RipObj.rButton(tx0,ty0,tx1,ty1,hotkey:word; flags:byte; icon:str12; sLabel,Cmd:string);
  775. type
  776.   IconHdr = record
  777.     tWid,
  778.     tHgt : word;
  779.   end;
  780.  
  781. var
  782.   Trapezoid : array[1..4] of PointType;
  783.  
  784.   BClip, BInvertable, BReset, BChisel, BRecess, BDropShadow, BImage2Clip,
  785.   BIconBut, BPlainBut, BBevel, BMouse, BUline, BHotIcons, BAdjustVert,
  786.   BRadio, BSunken, BCheckbox, BHilite, BExplode, BLeftJust, BRightJust   : Boolean;
  787.  
  788.   X0,Y0,X1,Y1                   : integer;
  789.   bWid,bHgt,tWid,tHgt,tX,tY     : integer;
  790.   TempX0,TempY0,TempX1,TempY1   : integer;
  791.   RecessTemp                    : Word;
  792.   T2                            : Word;
  793.   tst                           : TextSettingsType;
  794.   lst                           : LineSettingsType;
  795.   col                           : word; {color}
  796.   DoneHilite                    : boolean;
  797.   XChisel, YChisel              : Byte;
  798.  
  799.   cb            : pointer;
  800.   cb2           : pointer;
  801.   cbsize        : word;
  802.   IcnFile       : file;
  803.   thewid,thehgt : word;
  804.  
  805.   Function FlagOn(Flags : Word; FlagMask : Word) : Boolean;
  806.   begin
  807.     FlagOn := (Flags and FlagMask) <> 0;
  808.   end;
  809.  
  810.   procedure SetFlagOn(var Flags : Word; FlagMask : Word);
  811.   begin
  812.     Flags := Flags or FlagMask;
  813.   end;
  814.  
  815.   procedure SetFlagOff(var Flags : Word; FlagMask : Word);
  816.   begin
  817.     Flags := Flags and not FlagMask;
  818.   end;
  819.  
  820.   Procedure PutItXY(x,y : word; thelabel : string);
  821.   var
  822.     thecounter : byte;
  823.   begin
  824.     MoveTo(x,y);
  825.     for thecounter := 1 to length(thelabel) do
  826.     begin
  827.       if (not donehilite) and (upcase(thelabel[thecounter]) = char(hotkey)) then
  828.       begin
  829.         setcolor(ButLabelUnderline);
  830.         OutText(thelabel[thecounter]);
  831.         setcolor(ButLabelFore);
  832.         donehilite := true;
  833.       end
  834.       else
  835.         OutText(thelabel[thecounter]);
  836.     end;
  837.   end;
  838.  
  839.   Function Real_TextHeight: word;
  840.   begin
  841.     Real_TextHeight := Metric.Base - Metric.Top + 1;
  842.   end;
  843.  
  844.   Function Contains_DropDown(st:string): boolean;
  845.   var
  846.     ct : byte;
  847.   begin
  848.     contains_dropdown := true;
  849.     for ct := 1 to length(st) do
  850.     begin
  851.       if low_char[ord(st[ct])] = 1 then
  852.         exit;
  853.     end;
  854.     contains_dropdown := false;
  855.   end;
  856.  
  857. begin
  858.   if LocalRip then
  859.   begin
  860.     {$IFDEF MOUSE}
  861.     MouseOff;
  862.     {$ENDIF}
  863.     GetTextSettings(tst);
  864.     GetLineSettings(lst);
  865.     Col := GetColor;
  866.     SetColor(0);
  867.     {SetTextStyle(defaultfont,horizdir,1);}
  868.     SetLineStyle(SolidLn,0,NormWidth);
  869.  
  870. {+} BClip := FlagOn(ButFlags,1);
  871. {+} BInvertable := FlagOn(ButFlags,2);
  872. {+} BReset := FlagOn(ButFlags,4);
  873. {+} BChisel := FlagOn(ButFlags,8);
  874. {+} BRecess := FlagOn(ButFlags,16);
  875. {+} BDropShadow := FlagOn(ButFlags,32);
  876. {+} BImage2Clip := FlagOn(ButFlags,64);
  877. {+} BIconBut := FlagOn(ButFlags,128);
  878. {+} BPlainBut := FlagOn(ButFlags,256);
  879. {+} BBevel := FlagOn(ButFlags,512);
  880. {+} BMouse := FlagOn(ButFlags,1024);
  881. {-} BUline := FlagOn(ButFlags,2048);
  882. {-} BHotIcons := FlagOn(ButFlags,4096);
  883. {+} BAdjustVert := FlagOn(ButFlags,8192);
  884. {-} BRadio := FlagOn(ButFlags,16384);
  885. {+} BSunken := FlagOn(ButFlags,32768);
  886. {-} BCheckbox := FlagOn(ButFlags2,1);
  887. {+} BHilite := FlagOn(ButFlags2,2);
  888. {-} BExplode := FlagOn(ButFlags2,4);
  889. {+} BLeftJust := FlagOn(ButFlags2,8);
  890. {+} BRightJust := FlagOn(ButFlags2,16);
  891.     if not BMouse then
  892.     begin
  893.       BUline := false;
  894.       BInvertable := false;
  895.       BReset := false;
  896.       BHotIcons := false;
  897.       BRadio := false;
  898.       BCheckbox := false;
  899.       BHilite := false;
  900.       BExplode := false;
  901.     end;
  902.     if not BIconBut then
  903.     begin
  904.       BHotIcons := false;
  905.     end;
  906.     if BHilite then
  907.       DoneHilite := false
  908.     else
  909.       DoneHilite := true;
  910.  
  911.     {x/y adjustments based on button type go here}
  912.     x0 := tx0;
  913.     y0 := ty0;
  914.     x1 := tx1;
  915.     y1 := ty1;
  916.     if BPlainBut and ((tx1 = 0) and (ty1 = 0)) then
  917.     begin
  918.       x1 := tx0+ButPlainWidth;
  919.       y1 := ty0+ButPlainHeight;
  920.     end;
  921.     if BIconBut then
  922.     begin
  923.       filemode := $20;
  924.       assign(icnfile,backslash(IconDir)+icon);
  925.       {$I-}
  926.       reset(icnfile,1);
  927.       {$I+}
  928.       if IOresult <> 0 then
  929.       begin
  930.         {$IFDEF MOUSE}
  931.         MouseOn;
  932.         {$ENDIF}
  933.         exit;
  934.       end;
  935.       seek(IcnFile,0);
  936.       blockread(IcnFile,thewid,2);
  937.       blockread(IcnFile,thehgt,2);
  938.       cbsize := ImageSize(0,0,thewid,thehgt);
  939.       x1 := tx0+thewid;
  940.       y1 := ty0+thehgt;
  941.       getmem(cb,cbsize);
  942.       seek(IcnFile,0);
  943.       blockread(IcnFile,cb^,cbsize);
  944.       close(icnfile);
  945.     end;
  946.     if BClip then
  947.     begin
  948.       if clipb <> nil then
  949.       begin
  950.         thewid := iconhdr(clipb^).tWid;
  951.         thehgt := iconhdr(clipb^).tHgt;
  952.         x1 := tx0+thewid;
  953.         y1 := ty0+thehgt;
  954.       end;
  955.     end;
  956.  
  957.     SetColor(ButPlainSurface);
  958.     SetFillStyle(SolidFill,ButPlainSurface);
  959.     Bar(x0,y0,x1,y1);
  960.     if BSunken then
  961.     begin
  962.       SetColor(ButPlainShadow);
  963.       Line(x0,y0,x1,y0);
  964.       Line(x0,y0,x0,y1);
  965.       SetColor(ButPlainHiLite);
  966.       Line(x0,y1,x1,y1);
  967.       Line(x1,y0,x1,y1);
  968.       SetColor(ButCorner);
  969.       PutPixel(x0,y0,ButCorner);
  970.       PutPixel(x1,y0,ButCorner);
  971.       PutPixel(x0,y1,ButCorner);
  972.       PutPixel(x1,y1,ButCorner);
  973.     end;
  974.     if BRecess then
  975.     begin
  976.       if BBevel then
  977.         RecessTemp := ButBevelSize+2
  978.       else
  979.         RecessTemp := 2;
  980.       SetColor(0);
  981.       Rectangle(x0-recesstemp+1,y0-recesstemp+1,x1+recesstemp-1,y1+recesstemp-1);
  982.  
  983.       SetColor(ButPlainShadow);
  984.       Line(x0-RecessTemp,y0-RecessTemp,x1+RecessTemp,y0-RecessTemp);
  985.       Line(x0-RecessTemp,y0-RecessTemp,x0-RecessTemp,y1+RecessTemp);
  986.       SetColor(ButPlainHiLite);
  987.       Line(x1+RecessTemp,y0-RecessTemp,x1+RecessTemp,y1+RecessTemp);
  988.       Line(x0-RecessTemp,y1+RecessTemp,x1+RecessTemp,y1+RecessTemp);
  989.       SetColor(ButCorner);
  990.       PutPixel(x0-RecessTemp,y0-RecessTemp,ButCorner);
  991.       PutPixel(x1+RecessTemp,y0-RecessTemp,ButCorner);
  992.       PutPixel(x0-RecessTemp,y1+RecessTemp,ButCorner);
  993.       PutPixel(x1+RecessTemp,y1+RecessTemp,ButCorner);
  994.     end;
  995.     if BBevel then
  996.     begin
  997.       SetLineStyle(SolidLn,0,1);
  998.       SetFillStyle(SolidFill,ButPlainHiLite);
  999.       SetColor(ButPlainHiLite);
  1000.       Trapezoid[1].X := x0-ButBevelSize;  Trapezoid[1].Y := y0-ButBevelSize;
  1001.       Trapezoid[2].X := x0-1;             Trapezoid[2].Y := y0-1;
  1002.       Trapezoid[4].X := x1+ButBevelSize;  Trapezoid[4].Y := y0-ButBevelSize;
  1003.       Trapezoid[3].X := x1+1;             Trapezoid[3].Y := y0-1;
  1004.       FillPoly(4,Trapezoid);
  1005.       Trapezoid[4].X := x0-ButBevelSize;  Trapezoid[4].Y := y1+ButBevelSize;
  1006.       Trapezoid[3].X := x0-1;             Trapezoid[3].Y := y1+1;
  1007.       FillPoly(4,Trapezoid);
  1008.       SetFillStyle(SolidFill,ButPlainShadow);
  1009.       SetColor(ButPlainShadow);
  1010.       Trapezoid[1].X := x1+ButBevelSize;  Trapezoid[1].Y := y1+ButBevelSize;
  1011.       Trapezoid[2].X := x1+1;             Trapezoid[2].Y := y1+1;
  1012.       FillPoly(4,Trapezoid);
  1013.       Trapezoid[4].X := x1+ButBevelSize;  Trapezoid[4].Y := y0-ButBevelSize;
  1014.       Trapezoid[3].X := x1+1;             Trapezoid[3].Y := y0-1;
  1015.       FillPoly(4,Trapezoid);
  1016.       SetColor(ButCorner);
  1017.       Line(x0-ButBevelSize,y0-ButBevelSize,x0-1,y0-1);
  1018.       Line(x0-ButBevelSize,y1+ButBevelSize,x0-1,y1+1);
  1019.       Line(x1+1,y0-1,x1+ButBevelSize,y0-ButBevelSize);
  1020.       Line(x1+1,y1+1,x1+ButBevelSize,y1+ButBevelSize);
  1021.     end;
  1022.     if BChisel then
  1023.     begin
  1024.       case (y1-y0) of
  1025.         0..11    : begin  xchisel := 1;   ychisel := 1;  end;
  1026.         12..24   : begin  xchisel := 3;   ychisel := 2;  end;
  1027.         25..39   : begin  xchisel := 4;   ychisel := 3;  end;
  1028.         40..74   : begin  xchisel := 6;   ychisel := 5;  end;
  1029.         75..149  : begin  xchisel := 7;   ychisel := 5;  end;
  1030.         150..199 : begin  xchisel := 8;   ychisel := 6;  end;
  1031.         200..249 : begin  xchisel := 10;  ychisel := 7;  end;
  1032.         250..299 : begin  xchisel := 11;  ychisel := 8;  end;
  1033.         300..999 : begin  xchisel := 13;  ychisel := 9;  end;
  1034.       end;
  1035.       setcolor(ButPlainHiLite);
  1036.       rectangle(x0+xchisel+1,y0+ychisel+1,x1-xchisel,y1-ychisel);
  1037.       setcolor(ButPlainShadow);
  1038.       rectangle(x0+xchisel,y0+ychisel,x1-(xchisel+1),y1-(ychisel+1));
  1039.       putpixel(x0+xchisel,y1-ychisel,ButPlainShadow);
  1040.       putpixel(x1-xchisel,y0+ychisel,ButPlainShadow);
  1041.     end;
  1042.  
  1043.     if BIconBut then
  1044.     begin
  1045.       PutImage(tx0,ty0,cb^,0);
  1046.       freemem(cb,cbsize);
  1047.     end;
  1048.     if BClip then
  1049.     begin
  1050.       if clipb <> nil then
  1051.         PutImage(tx0,ty0,clipb^,0);
  1052.     end;
  1053.     if BImage2Clip or BMouse then
  1054.     begin
  1055.       tempx0 := x0;  tempx1 := x1;
  1056.       tempy0 := y0;  tempy1 := y1;
  1057.       if BBevel then
  1058.       begin
  1059.         dec(tempx0,butbevelsize);
  1060.         dec(tempy0,butbevelsize);
  1061.         inc(tempx1,butbevelsize);
  1062.         inc(tempy1,butbevelsize);
  1063.       end;
  1064.     end;
  1065.     if BImage2Clip then
  1066.     begin
  1067.       if clipb <> nil then
  1068.       begin
  1069.         FreeMem(ClipB,ClipSize);
  1070.         ClipSize := 0;
  1071.         ClipB := nil;
  1072.       end;
  1073.       clipsize := ImageSize(tempx0,tempy0,tempx1,tempy1);
  1074.       GetMem(ClipB,ClipSize);
  1075.       GetImage(tempx0,tempy0,tempx1,tempy1,clipb^);
  1076.     end;
  1077.     if BMouse then
  1078.     begin
  1079.       {$IFDEF MOUSE}
  1080.       AddRegion(tempx0,tempy0,tempx1,tempy1,BInvertable,BReset,cmd);
  1081.       {$ENDIF}
  1082.     end;
  1083.  
  1084.     if sLabel <> '' then
  1085.     begin
  1086.       bwid := x1-x0;
  1087.       bhgt := y1-y0;
  1088.       if BBevel then
  1089.       begin
  1090.         inc(bwid,2*butbevelsize);
  1091.         inc(bhgt,2*butbevelsize);
  1092.         dec(x0,butbevelsize);
  1093.         dec(y0,butbevelsize);
  1094.         inc(x1,butbevelsize);
  1095.         inc(y1,butbevelsize);
  1096.       end;
  1097.       twid := textwidth(slabel);
  1098.       thgt := real_textheight;
  1099.       if brecess then
  1100.       begin
  1101.         dec(x0,2);
  1102.         dec(y0,2);
  1103.         inc(x1,2);
  1104.         inc(y1,2);
  1105.       end;
  1106.  
  1107.       case ButOrientation of
  1108.   {top} 0 : begin
  1109.               if bleftjust then
  1110.               begin
  1111.                 if bchisel then
  1112.                   tx := x0+20
  1113.                 else
  1114.                   tx := x0+10;
  1115.               end
  1116.               else
  1117.                 if brightjust then
  1118.                 begin
  1119.                   if bchisel then
  1120.                     tx := x0+bwid-twid-20
  1121.                   else
  1122.                     tx := x0+bwid-twid-10;
  1123.                 end
  1124.                 else
  1125.                   tx := x0+((bwid-twid) div 2);
  1126.               ty := y0-5-thgt;
  1127.               if contains_dropdown(slabel) and badjustvert then
  1128.                 dec(ty,(metric.drop-metric.base));
  1129.             end;
  1130.  {left} 1 : begin
  1131.               if contains_dropdown(slabel) and badjustvert then
  1132.                 inc(thgt,(metric.drop-metric.base));
  1133.               tx := x0-twid-8;
  1134.               ty := y0+((bhgt-thgt) div 2)+2;
  1135.               if buline then
  1136.                 dec(ty,1);
  1137.               if contains_dropdown(slabel) then
  1138.                 inc(ty,(metric.drop-metric.base) div 2);
  1139.             end;
  1140. {center}2 : begin
  1141.               if contains_dropdown(slabel) and badjustvert then
  1142.                 inc(thgt,(metric.drop-metric.base));
  1143.               if bleftjust then
  1144.               begin
  1145.                 if bchisel then
  1146.                   tx := x0+20
  1147.                 else
  1148.                   tx := x0+10;
  1149.               end
  1150.               else
  1151.                 if brightjust then
  1152.                 begin
  1153.                   if bchisel then
  1154.                     tx := x0+bwid-twid-20
  1155.                   else
  1156.                     tx := x0+bwid-twid-10;
  1157.                 end
  1158.                 else
  1159.                   tx := x0+((bwid-twid) div 2);
  1160.               ty := y0 + ((bhgt-thgt) div 2)+1;
  1161.             end;
  1162. {right} 3 : begin
  1163.               if contains_dropdown(slabel) and badjustvert then
  1164.                 inc(thgt,(metric.drop-metric.base));
  1165.               tx := x1+8;
  1166.               ty := y0+((bhgt-thgt) div 2)+2;
  1167.               if buline then
  1168.                 dec(ty,1);
  1169.               if contains_dropdown(slabel) then
  1170.                 inc(ty,(metric.drop-metric.base) div 2);
  1171.             end;
  1172. {bottom}4 : begin
  1173.               if bleftjust then
  1174.               begin
  1175.                 if bchisel then
  1176.                   tx := x0+20
  1177.                 else
  1178.                   tx := x0+10;
  1179.               end
  1180.               else
  1181.                 if brightjust then
  1182.                 begin
  1183.                   if bchisel then
  1184.                     tx := x0+bwid-twid-20
  1185.                   else
  1186.                     tx := x0+bwid-twid-10;
  1187.                 end
  1188.                 else
  1189.                   tx := x0+((bwid-twid) div 2);
  1190.               ty := y1+3;
  1191.             end;
  1192.       end; {case}
  1193.       if brecess then
  1194.       begin
  1195.         inc(ty,2);
  1196.         inc(tx,2);
  1197.       end;
  1198.       if bclip then
  1199.       begin
  1200.         if not contains_dropdown(slabel) then
  1201.           dec(ty,1);
  1202.       end
  1203.       else
  1204.         if (biconbut or bplainbut) then
  1205.           dec(ty,1);
  1206.  
  1207.       {display label finally}
  1208.       if bdropshadow then
  1209.       begin
  1210.         setcolor(butlabeldropshadow);
  1211.         outtextxy(tx+1,ty+1-metric.top,slabel);
  1212.       end;
  1213.       setcolor(butlabelfore);
  1214.       putitxy(tx,ty-metric.top,slabel);
  1215.     end; {if slabel...}
  1216.     if BImage2Clip then
  1217.     begin
  1218.       SetFlagOn(ButFlags,1);
  1219.       SetFlagOff(ButFlags,128);
  1220.       SetFlagOff(ButFlags,256);
  1221.       SetFlagOff(ButFlags,8);
  1222.       SetFlagOff(ButFlags,512);
  1223.       SetFlagOff(ButFlags,64);
  1224.       SetFlagOff(ButFlags,32768);
  1225.     end;
  1226.  
  1227.     SetColor(col);
  1228.     with tst do
  1229.       SetTextStyle(font,direction,charsize);
  1230.     with lst do
  1231.       SetLineStyle(LineStyle,Pattern,Thickness);
  1232.     {$IFDEF MOUSE}
  1233.     MouseOn;
  1234.     {$ENDIF}
  1235.  
  1236.   end;
  1237. end;
  1238.